﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL=IrisGenerator.Dal;
using System.Data;

namespace IrisGenerator.Common.DatabaseModel.DataAccess
{
    public class Constraint : IDisposable
    {
        private DAL.DataAccess _dataAccess;

        public Constraint()
        {
            this._dataAccess = new DAL.DataAccess();
        }

        public virtual System.Nullable<System.Guid> Constraint_Insert(string Name,Guid? tableId,Guid? typeId)
        {
            this._dataAccess.CreateProcedureCommand("sp_Constraint_Insert");
            this._dataAccess.AddParameter("name", Name, ParameterDirection.Input);
            this._dataAccess.AddParameter("tabid", tableId, ParameterDirection.Input);
            this._dataAccess.AddParameter("typid", typeId, ParameterDirection.Input);
            Guid value = ((Guid)(this._dataAccess.ExecuteScalar()));
            return value;
        }

        public virtual void Dispose()
        {
            if ((this._dataAccess != null))
            {
                this._dataAccess.Dispose();
            }
        }

        public virtual DataSet TableConstraints(Guid? tableId)
        {
            this._dataAccess.CreateProcedureCommand("TableConstraints");
            this._dataAccess.AddParameter("tableId", tableId, ParameterDirection.Input);
            DataSet value = ((this._dataAccess.ExecuteDataSet()));
            return value;
        }

        public virtual DataSet SelectOne(Guid? consId)
        {
            this._dataAccess.CreateProcedureCommand("Constraint_SelectOne");
            this._dataAccess.AddParameter("consId", consId, ParameterDirection.Input);
            DataSet value = ((this._dataAccess.ExecuteDataSet()));
            return value;
        }

    }
}
